package com.wiscamp.ninechapters.problems.math;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 分数
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class LatexFraction extends LatexNumber {
    private int prefixNumber = 0;

    private int denominator = 0;

    private int numerator = 0;

    private String symbol = "";


    public String getLatex() {
        if (symbol.equals("+"))
            symbol = "";
        String prefixNumberText = "";
        if (prefixNumber > 0)
            prefixNumberText = String.valueOf(prefixNumber);
        return String.format("%s%s\\frac{%d}{%d}", symbol, prefixNumberText, numerator, denominator);
    }

    public LatexFraction() {

    }

    public LatexFraction(String symbol, int prefixNumber, int numerator, int denominator) {
        this.symbol = symbol;
        this.prefixNumber = prefixNumber;
        this.numerator = numerator;
        this.denominator = denominator;
    }
}
